<?php	require(dirname(__FILE__).'/inc/config.inc.php');

/*
**************************
(C)2010-2013 phpMyWind.com
update: 2011-5-5 20:06:22
person: 丶Terry
**************************
*/


//初始化参数
$tbname = '#@__lang';


//跳转地址
$gourl = 'lang.php';


//引入操作类
require(ADMIN_INC.'/action.class.php');


//添加栏目
if($action == 'add')
{
	//var_dump($_POST);exit;
	$lang_key = trim($lang_key);
	$sql = "INSERT INTO `$tbname` (siteid, lang_key, cn_name, en_name ) VALUES ('$cfg_siteid', '$lang_key', '$cn_name', '$en_name')";
	if($dosql->ExecNoneQuery($sql))
	{
		header("location:$gourl");
		exit();
	}
}


//修改栏目
else if($action == 'update')
{

	$lang_key = trim($lang_key);
	
		$sql = "UPDATE `$tbname` SET siteid='$cfg_siteid', lang_key='$lang_key', cn_name='$cn_name', en_name='$en_name' WHERE id=$id";

	if($dosql->ExecNoneQuery($sql))
	{
		header("location:$gourl");
		exit();
	}
}

	
//删除栏目
else if($action == 'delitem')
{
	//删除栏目
	$dosql->ExecNoneQuery("DELETE FROM `$tbname` WHERE id=$id");

	header("location:$gourl");
	exit();
}


//删除全选栏目
else if($action == 'delallitem')
{
	
	//删除栏目的单页信息
	foreach($checkid as $k => $v)
	{
		//删除栏目
		$dosql->ExecNoneQuery("DELETE FROM `$tbname` WHERE id=$v");
	}

	header("location:$gourl");
	exit();
}
//生成语言文件
else if($action == 'createphp'){
 	    $dosql->Execute("SELECT * FROM `$tbname`");
		while($row = $dosql->GetArray())
		{
			$data['cn'][$row['lang_key']] = $row['cn_name'];
			$data['en'][$row['lang_key']] = $row['en_name'];
		}
		create_file('language','cn.php',$data['cn'],$flags=FILE_USE_INCLUDE_PATH);
		create_file('language','en.php',$data['en'],$flags=FILE_USE_INCLUDE_PATH);
		header("location:$gourl");
		exit();
}



//无条件返回
else
{
    header("location:$gourl");
	exit();
}
?>